package com.nioSocketCore.chapter01;

import java.nio.CharBuffer;

/**
 * @author : wushikai
 * date : 2022-04-29
 */
public class BufferPositionDemo {


    public static void main(String[] args) {
        char[] charArray = new char[]{'a', 'b', 'c', 'd'};
        CharBuffer charBuffer = CharBuffer.wrap(charArray);

        System.out.println(" A capacity () =" + charBuffer.capacity() + " limit() =" + charBuffer.limit() + "  position() = " + charBuffer.position());
        charBuffer.position(2);
        System.out.println(" A capacity () =" + charBuffer.capacity() + " limit() =" + charBuffer.limit() + "  position() = " + charBuffer.position());
        charBuffer.put("e");  //  a b e d  ;  e将 在 第3个位置
        for (char c : charArray) {
            System.out.print(c);
        }

    }


}
